﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace _2011DBProject
{
    public partial class LockerRoom : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void gvLockerRoom_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                lblItem.Text = gvLockerRoom.DataKeys[gvLockerRoom.SelectedIndex].Values[0].ToString();
                lblUnique.Text = gvLockerRoom.DataKeys[gvLockerRoom.SelectedIndex].Values[1].ToString();
                lblCharacterName.Text = gvLockerRoom.DataKeys[gvLockerRoom.SelectedIndex].Values[2].ToString();
            }
            catch (Exception)
            {
                throw;
            }
        }

        protected void btnMoveToInventory_Click(object sender, EventArgs e)
        {
            try
            {
                if (lblItem.Text == "선택된 아이템이 없습니다.") return;
                DataSet1TableAdapters.MY_ITEMTableAdapter taMyItem = new _2011DBProject.DataSet1TableAdapters.MY_ITEMTableAdapter();
                taMyItem.Connection.ConnectionString = Settings.strConnectionString;
                DataSet1.MY_ITEMDataTable dtMyItem = taMyItem.GetDataByServerNoCharacterNameItemNoUniqItemNo(Settings.decServer, lblCharacterName.Text, Convert.ToDecimal(lblItem.Text), Convert.ToDecimal(lblUnique.Text));
                if (dtMyItem.Count > 0)
                {
                    DataSet1.MY_ITEMRow row = dtMyItem[0];
                    row.CHARACTER_NAME = ddCharacterName.SelectedValue;
                    row.CADDIE_EQUIP = "N";
                    row.CHARACTER_EQUIP = "N";
                    row.LOCKERROOM_KEEP = "N";
                    taMyItem.Update(dtMyItem);
                    sqldsLockerRoom.DataBind();
                    gvLockerRoom.DataBind();
                }
            }
            finally
            {
                lblItem.Text = "선택된 아이템이 없습니다.";
            }
        }

        protected void btnGoLogout_onclick(object sender, EventArgs e)
        {
            Session.Clear();
            Response.Redirect("Default.aspx");
        }
        protected void btnGoServer_onclick(object sender, EventArgs e)
        {
            Response.Redirect("Server.aspx");
        }
        protected void btnGoCharacter_onclick(object sender, EventArgs e)
        {
            Response.Redirect("Character.aspx");
        }
    }
}
